#include "BasicOpt.h"

// Previous Order Travel of Binary Tree
void PreOrderTravel(BinTree BT){
    if(BT){
        Visit(BT->num);
        PreOrderTravel(BT->Left);
        PreOrderTravel(BT->Right);
    }
}

// In Order Travel of binary tree
void InOrderTravel(BinTree BT){
    if(BT){
        InOrderTravel(BT->Left);
        Visit(BT->num);
        InOrderTravel(BT->Right);
    }
}

// In Order Travel of binary tree with non-recursion method
void NonRecursionIOT(BinTree BT){
    BinTree BTree;
    Stack S;
    S = CreateStack();
    Push(S, BT);
    while (!StackEmpty(S)){
        if(BT->Left){
            
        }
    }
}

// Post Order travel of binary tree
void PostOrderTravel(BinTree BT){
    if(BT){
        PostOrderTravel(BT->Left);
        PostOrderTravel(BT->Right);
        Visit(BT->num);
    }
}

// Level Order travel of binary tree
void LevelOrderTravel(BinTree BT){
    Queue Q;
    BinTree T;
    if(!BT){
        return;
    }
    Q = CreateQueue();
    AddQ(Q, BT);
    while (!IsEmptyQue(Q))
    {
        T = DeleteQ(Q);
        Visit(T->num);
        if (T->Left)
        {
            AddQ(Q, T->Left);
        }
        if(T->Right){
            AddQ(Q, T->Right);
        }
    }
}

void Visit(int num){
    printf("%d",num);
}